package config

import "fmt"

// Config 配置信息
type Config struct {
	Host     string
	Port     int
	Username string
	Password string
	Parama   string    //数据库连接其他字符串，eg:charset
	DB       string
	Tables   []string
	Viewer   string
	Debug    bool
}
func CreateConfig(Host string,Port int, Username string, Password string, Parama   string  , DB string, Tables   []string, Viewer   string,Debug bool)*Config{
     return &Config{
     	Host:Host,
     	Port:Port,
     	Username:Username,
     	Password:Password,
     	Parama:Parama,
     	DB:DB,
     	Tables:Tables,
     	Viewer:Viewer,
     	Debug:Debug,
	 }
}
func (c Config)GetDatasourceString()string{
	if c.Password == "" {
		return fmt.Sprintf("%s@tcp(%s:%d)/information_schema?%s", c.Username, c.Host, c.Port, c.Parama)
	}
	return fmt.Sprintf("%s:%s@tcp(%s:%d)/information_schema?%s", c.Username, c.Password, c.Host, c.Port, c.Parama)
}

func(c Config)GetOutputType()string{
	return c.Viewer
}

